package com.navcoo.yidaaddproapi.controller;

import com.navcoo.yidaaddproapi.pojo.dto.user.CreateUserDTO;
import com.navcoo.yidaaddproapi.response.Result;
import com.navcoo.yidaaddproapi.service.UserService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 用户控制器
 *
 * @author Navcoo
 * @date 2024-04-24
 */
@Slf4j
@RestController
@RequiredArgsConstructor
@RequestMapping("/api/user")
public class UserController {

    private final UserService userService;

    /**
     * 创建用户
     *
     * @param createUserDTO 创建用户DTO
     * @return {@link Result}<{@link String}>
     */
    @RequestMapping("/createUser")
    public Result<String> createUser(@RequestBody CreateUserDTO createUserDTO) {
        return userService.createUser(createUserDTO.getUserEmail(), createUserDTO.getUserName(), createUserDTO.getPassword(), createUserDTO.getAvatar());
    }

    /**
     * 删除用户
     *
     * @param username 用户名
     * @param password 密码
     */
    @RequestMapping("/deleteUser")
    public void deleteUser(String username, String password) {
        userService.deleteUser(username, password);
    }

    /**
     * 更新用户信息
     *
     * @param username 用户名
     * @param password 密码
     */
    @RequestMapping("/updateUserInfo")
    public void updateUserInfo(String username, String password) {
        userService.updateUserInfo(username, password);
    }

    /**
     * 获取用户信息
     *
     * @param username 用户名
     * @param password 密码
     */
    @RequestMapping("/getUserInfo")
    public void getUserInfo(String username, String password) {
        userService.getUserInfo(username, password);
    }
}
